package com.cf.main;

public class ProduceMAE implements Base {
	public double[] produceMAE(double[][] m, int[][] test) {
		double mae = 0.0;
		double[] mm = new double[TEST_DATA_COUNT];
		//int qq = 0;
		for (int i = 0; i < USERSIZE; i++) {
			double sum_fencha = 0.0;
			int num = 0;
			for (int j = 0; j < ITEMSIZE; j++) {
				if (!equal(m[i][j], 0.0d) && test[i][j] != 0) {
					sum_fencha += Math.abs(m[i][j] - (double) test[i][j]);
					// System.out.print(m[i][j] + "," + test[i][j] + " ");
					num++;
					//qq++;
				}
			}
			if (num == 0)
				mae = 0;
			else
				mae = sum_fencha / num;
			mm[i] = mae;
		}
		//System.out.println(qq);
		return mm;
	}

	static boolean equal(double num1, double num2) {
		if ((num1 - num2 > -0.000001) && (num1 - num2) < 0.000001)
			return true;
		else
			return false;
	}
}
